<?php

		// CODE IS NO LONGER IN USE
		// 3-30-2011

		/*
		include '../include/db.php';
		$username = $_SESSION['username'];
		$user_result = mysql_query("SELECT * FROM users WHERE username='$username'");
		$user_id = mysql_result($user_result, 0, "id");
		$hospital_result = mysql_query("SELECT id FROM hospitals WHERE owner_id='$user_id'");
		$hospital_id = mysql_result($hospital_result, 0, "id");
		$cash = getPlayerCash();	
		$price = 0;
		$roomids = array();
		for ($i = 0; $i < mysql_num_rows(mysql_query("SELECT name FROM room_types")); $i++)
		{
			$x = $i + 1;
			$result = mysql_query("SELECT id,price FROM room_types");
			$room_id = mysql_result($result, $i, "id");
			$room_price = mysql_result($result, $i, "price");
			$price = $price + ($room_price * $_POST[$x]);
			$roomids[$i] = $room_id;
		}
		if ($price > $cash)
		{
			echo "The cost (\$".$price.") is too much for you. You currently have \$".$cash.".";
		} else {
			$cash = $cash - $price;
			mysql_query("UPDATE users SET cash=$cash WHERE username='$username'");
			for ($i = 0; $i < count($roomids); $i++)
			{
				mysql_query("INSERT INTO rooms (hospital_id,type_id) VALUES ($hospital_id, 			
				{$roomids[$i]})");
			}
			echo "Rooms successfully purchased. You now have \$$cash.";
		}
		
		function getPlayerCash()
	{
		$username = $_SESSION['username'];
		$result = mysql_query("SELECT cash FROM users WHERE username='$username'");
		$cash = mysql_result($result, 0);
		if ($cash != NULL) {
			return $cash;
		} else { return 0; }
	}
	*/

?>